<?php
include_once 'Application.php';
class AbstractView {
	private $applicationInctance;
	public function __construct() {
		$this->applicationInctance = Application::getInstance ();
	}
	protected function getUserRepository() {
		return $this->applicationInctance->getUserRepository ();
	}
	protected function getContentRepository() {
		return $this->applicationInctance->getContentRepository ();
	}
	protected function redirect($page) {
		header ( "Location: " . $page );
	}
	protected function invokedByUser() {
		$user = $this->applicationInctance->getActiveUser ();
		if ($user == NULL) {
			return false;
		}
		
		return ($user->getPrivileges () === User::USER_PRIVILEGES);
	}
	protected function getActiveUser() {
		$user = $this->applicationInctance->getActiveUser ();
		return $user;
	}
	protected function invokedByAdmin() {
		$user = $this->applicationInctance->getActiveUser ();
		if ($user == NULL) {
			return false;
		}
		
		return ($user->getPrivileges () === User::ADMIN_PRIVILEGES);
	}
	protected function block() {
		$this->redirect ( "blocker.php" );
	}
}
?>